<html>
<head><meta charset="utf-8"><title>Cranelift Native Windows · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Cranelift.20Native.20Windows.html">Cranelift Native Windows</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="224822202"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Cranelift%20Native%20Windows/near/224822202" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> CraftSpider <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Cranelift.20Native.20Windows.html#224822202">(Feb 02 2021 at 02:43)</a>:</h4>
<p>Just for fun, I'm trying to compile cranelift natively on windows. I can build cranelift, trying to build sysroot results in an assertion failure when I get to compiling libc (with or without cherry-picking wip_windows_support3):</p>
<div class="codehilite"><pre><span></span><code>   Compiling core v0.0.0 (D:\Dev\Git\rustc_codegen_cranelift\build_sysroot\sysroot_src\library\core)
   Compiling rustc-std-workspace-core v1.99.0 (D:\Dev\Git\rustc_codegen_cranelift\build_sysroot\sysroot_src\library\rustc-std-workspace-core)
   Compiling compiler_builtins v0.1.39 (D:\Dev\Git\rustc_codegen_cranelift\build_sysroot\compiler-builtins)
[rustc_std_workspace_core      : codegen mono items] start
[rustc_std_workspace_core      : codegen mono items] end time: 1.2314ms
   Compiling libc v0.2.84
[libc                          : codegen mono items] start
thread &#39;rustc&#39; panicked at &#39;int args only supported for SysV calling convention&#39;, C:\Users\runet\.cargo\git\checkouts\wasmtime-41807828cb3a7a7e\986b576\cranelift\codegen\src\isa\x64\abi.rs:749:14
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic

error: Unrecognized option: &#39;clif&#39;

Instance { def: Item(WithOptConstParam { did: DefId(0:65 ~ libc[2b91]::windows::{impl#1}::clone), const_param_did: None }), substs: [] } _ZN62_$LT$libc..windows..timezone$u20$as$u20$core..clone..Clone$GT$5clone17h06c26bc747eab085E
error: could not compile `libc`

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
[core                          : codegen mono items] start
thread &#39;rustc&#39; panicked at &#39;int args only supported for SysV calling convention&#39;, C:\Users\runet\.cargo\git\checkouts\wasmtime-41807828cb3a7a7e\986b576\cranelift\codegen\src\isa\x64\abi.rs:749:14
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic

error: Unrecognized option: &#39;clif&#39;

Instance { def: DropGlue(DefId(0:1663 ~ core[55a8]::ptr::drop_in_place), None), substs: [&amp;i8] } _ZN4core3ptr27drop_in_place$LT$$RF$i8$GT$17hd0c662a06d30e437E
[compiler_builtins             : codegen mono items] start
thread &#39;rustc&#39; panicked at &#39;not yet implemented&#39;, C:\Users\runet\.cargo\git\checkouts\wasmtime-41807828cb3a7a7e\986b576\cranelift\codegen\src\isa\x64\abi.rs:824:90
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic

error: Unrecognized option: &#39;clif&#39;

Instance { def: Item(WithOptConstParam { did: DefId(0:336 ~ compiler_builtins[c8c4]::float::conv::__floatsisf), const_param_did: None }), substs: [] } _ZN17compiler_builtins5float4conv11__floatsisf17h9eebe69e2fe6a727E
error: build failed
</code></pre></div>



<a name="224822257"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Cranelift%20Native%20Windows/near/224822257" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> CraftSpider <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Cranelift.20Native.20Windows.html#224822257">(Feb 02 2021 at 02:44)</a>:</h4>
<p>So I guess it's time to look at wasmtime itself, as that's where the actual failure is coming from</p>



<a name="224822306"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Cranelift%20Native%20Windows/near/224822306" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> CraftSpider <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Cranelift.20Native.20Windows.html#224822306">(Feb 02 2021 at 02:46)</a>:</h4>
<p>Actually, first, check cranelift to see if <code>ise::x64</code> is actually what's wanted here</p>



<a name="224822619"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Cranelift%20Native%20Windows/near/224822619" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> CraftSpider <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Cranelift.20Native.20Windows.html#224822619">(Feb 02 2021 at 02:52)</a>:</h4>
<p>Debugging:<br>
Okay, the errors happening in libc and core:<br>
In <code>core</code>, while trying to generate drop glue for <code>core::ptr::drop_in_place</code><br>
In <code>core</code> again, a 'not yet implemented' while trying to generate code for <code>compiler_builtins::float::conv::__floatsisf</code><br>
In <code>libc</code>, while trying to codegen <code>impl ::Clone for timezone</code> in <code>libc::windows</code></p>



<a name="224823588"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Cranelift%20Native%20Windows/near/224823588" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> CraftSpider <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Cranelift.20Native.20Windows.html#224823588">(Feb 02 2021 at 03:13)</a>:</h4>
<p>Trying to get a local build of wasmtime for testing changes, but I'm having issues where uncommenting all the patches but gimli results in mismatched types, <code>cranelift_object::object::*</code> not being the same as <code>object::*</code></p>



<a name="224834126"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Cranelift%20Native%20Windows/near/224834126" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Cranelift.20Native.20Windows.html#224834126">(Feb 02 2021 at 06:41)</a>:</h4>
<p>Yeah, the new x64 backend doesn't yet have support for the <code>WindowsFastcall</code> calling convention. There is also no PE style TLS support for both the old and new backend.</p>



<a name="224896821"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Cranelift%20Native%20Windows/near/224896821" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> CraftSpider <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Cranelift.20Native.20Windows.html#224896821">(Feb 02 2021 at 16:33)</a>:</h4>
<p>Is there any solution for the type mismatch, trying to use a local cranelift checkout? I probably won't have too much time to sink into this, but I can't even get a patched cranelift to build.</p>



<a name="224897214"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Cranelift%20Native%20Windows/near/224897214" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> CraftSpider <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Cranelift.20Native.20Windows.html#224897214">(Feb 02 2021 at 16:36)</a>:</h4>
<p>Thank you for all your work on this, I don't mean to take up too much of your time. I like the idea of it on Windows, but this is just a little 'Huh, can I get it working' project for me.</p>



<a name="224897561"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Cranelift%20Native%20Windows/near/224897561" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Cranelift.20Native.20Windows.html#224897561">(Feb 02 2021 at 16:38)</a>:</h4>
<p>For me the <code>wip_windows_support3</code> branch "works" when cross-compiling to mingw from linux using <code>TARGET_TRIPLE=x86_64-pc-windows-gnu ./test.sh --oldbe</code>. 128bit shift operations don't work (used for some float operations) and thread local storage isn't thread local.</p>



<a name="224897842"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Cranelift%20Native%20Windows/near/224897842" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Cranelift.20Native.20Windows.html#224897842">(Feb 02 2021 at 16:40)</a>:</h4>
<p>The type mismatch when using a local wasmtime checkout may be because I haven't yet updated to the latest cranelift and object version.</p>



<a name="224897977"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Cranelift%20Native%20Windows/near/224897977" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Cranelift.20Native.20Windows.html#224897977">(Feb 02 2021 at 16:41)</a>:</h4>
<p>I think commit <a href="https://github.com/rust-lang/rust/commit/57c686d49d58cbc5af7dda14e8dce4470f138f20">57c686d49d58cbc5af7dda14e8dce4470f138f20</a> of wasmtime will work. This is the commit just it updated the object dependency.</p>



<a name="224898012"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Cranelift%20Native%20Windows/near/224898012" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Cranelift.20Native.20Windows.html#224898012">(Feb 02 2021 at 16:41)</a>:</h4>
<p><span class="user-mention" data-user-id="319144">@CraftSpider</span> ^</p>



<a name="224905921"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Cranelift%20Native%20Windows/near/224905921" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> CraftSpider <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Cranelift.20Native.20Windows.html#224905921">(Feb 02 2021 at 17:28)</a>:</h4>
<p>That commit works to build, thanks. cherry-picking wip_windows_support3 doesn't fix the calling issues, but is probably necessary in general.<br>
For calling convention: Wooh, WindowsFastcall apparently requires you to know the <em>size</em> of the arguments as well as their index, meaning the existing functions in <code>abi.rs</code> need alteration to be given more context</p>



<a name="224906554"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Cranelift%20Native%20Windows/near/224906554" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Cranelift.20Native.20Windows.html#224906554">(Feb 02 2021 at 17:32)</a>:</h4>
<p>wip_windows_support3 among some other things fixes the abi used for most 128bit int ops.</p>



<a name="224933502"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Cranelift%20Native%20Windows/near/224933502" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> CraftSpider <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Cranelift.20Native.20Windows.html#224933502">(Feb 02 2021 at 20:42)</a>:</h4>
<p>(Note, I said something silly in 'needs size', it's asking for an int. But it's still possibly an issue with context, I need to understand the actual call-sites. Time for some fun)</p>



<a name="224940158"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Cranelift%20Native%20Windows/near/224940158" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> CraftSpider <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Cranelift.20Native.20Windows.html#224940158">(Feb 02 2021 at 21:34)</a>:</h4>
<p>Wish I could <code>#[cfg(not(cranelift))]</code> or such, is there an equivalent? Or would I just have to make a patch file</p>



<a name="224940410"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Cranelift%20Native%20Windows/near/224940410" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> CraftSpider <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Cranelift.20Native.20Windows.html#224940410">(Feb 02 2021 at 21:37)</a>:</h4>
<p>I also realised I didn't read well, WindowsFastcall on x64 is just the x64 convention, and that isn't hard to implement (Assuming I did it right. I probably didn't, but it <em>should</em> be easy to fix as long as I can figure out what part I mixed up)</p>



<a name="224949974"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Cranelift%20Native%20Windows/near/224949974" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Cranelift.20Native.20Windows.html#224949974">(Feb 02 2021 at 23:01)</a>:</h4>
<p>There is no <code>#[cfg]</code> for cg_clif. At the time custom codegen backends are initialized the <code>Session</code> that contains a full list of them is already immutable.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>